
/*活动*/
//活动列表
function playListClick(){
	$("#Huifold a[href=playList]").click();
}
function playList(pageNo){
	 //给栏目表录入数据
	if(!pageNo){pageNo=1}		//分页页数
    mccmsa.ajax({
        url:"activity/list/0?pageNo="+pageNo+"&pageSize=8",
        method:"Get",
        success:function(json){
        	for(var i in json.result.resultList){
        		json.result.resultList[i].beginTime=returnDate(json.result.resultList[i].beginTime);
        		json.result.resultList[i].status=returnStatus(json.result.resultList[i].status);
        	}

        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navMain",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData",
                container: $("#ColumnTableData"),
                data:json
            });
			pageHtml(json);		//生成分页
            $("#playList").show();
            $("#onClickDataTable").hide(); 
			
            var scrollbarWidth = $('.table-maxHeight')[0].offsetWidth - $('.table-maxHeight')[0].scrollWidth;
            $("table:eq(0)").css("paddingRight",scrollbarWidth);    //获取滚动条宽度并赋值到表头padding-right，对齐
        }
    })
}
//活动查询
function playListCheck(obj){
	mccmsa.ajax({
        url:"activity/getById/"+$(obj).parents("tr").attr("actId"),
        method:"GET",
        success:function(json){
        	json.result.beginTime=returnDate(json.result.beginTime);
        	json.result.endTime=returnDate(json.result.endTime);
        	json.result.enrollBeginTime=returnDate(json.result.enrollBeginTime);
        	json.result.enrollEndTime=returnDate(json.result.enrollEndTime);
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navCheck",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckData",
                container: $("#onClickDataTable"),
                data:json
            });
            
            if(json.result.actPhotoName!=null){
            	$("#preview").attr("src","upload/enterprice/image/"+json.result.actPhotoName);
				$("#preview").parent().find(".shadeFile").html(json.result.actPhotoName.substring(json.result.actPhotoName.lastIndexOf("/")+1))
			}
            
            
            $("#playList").hide();
            $("#onClickDataTable").show(); 
            
            /*//获取滚动条宽度并赋值到表头padding-right，对齐
        	//实例化编辑器
        	//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
            editor = new UE.ui.Editor();
            editor.render("editor");*/
        }
    })
}
//活动编辑
function playListEdit(obj){
	mccmsa.ajax({
        url:"activity/getById/"+$(obj).parents("tr").attr("actId"),
        method:"GET",
        success:function(json){
        	json.result.beginTime=returnDate(json.result.beginTime);
        	json.result.endTime=returnDate(json.result.endTime);
        	json.result.enrollBeginTime=returnDate(json.result.enrollBeginTime);
        	json.result.enrollEndTime=returnDate(json.result.enrollEndTime);
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navCheck",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getEditData",
                container: $("#onClickDataTable"),
                data:json
            });
            
            if(json.result.actPhotoName!=null){
            	$("#preview").attr("src","upload/enterprice/image/"+json.result.actPhotoName);
				$("#preview").parent().find(".shadeFile").html(json.result.actPhotoName.substring(json.result.actPhotoName.lastIndexOf("/")+1))
			}
            
            $("#playList").hide();
            $("#onClickDataTable").show(); 
            
            dataLay();
            
            //获取滚动条宽度并赋值到表头padding-right，对齐
        	//实例化编辑器
        	//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
            editor = new UE.ui.Editor();
            editor.render("editor");
            
            //判断ueditor 编辑器是否创建成功
			editor.addListener("ready", function() {
				// editor准备好之后才可以使用
				if(json.result.moreDetails!=null){
					editor.setContent(json.result.moreDetails);
				}
			});
            
            $("#onClickDataTable>tbody>tr:last").after('<tr><td class="col-1 table-bgc-f5"></td><td class="text-l col-11"> <input class="btn btn-primary radius"  onClick="playListEditPost()" type="submit" value="提交"></td></tr>');
        }
    })
}
function dataLay(){
	laydate({
        elem: '#beginTime',
		istime: true,
		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
    });
	laydate({
        elem: '#endTime',
		istime: true,
		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
    });
	laydate({
        elem: '#enrollBeginTime',
		istime: true,
		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
    });
	laydate({
        elem: '#enrollEndTime',
		istime: true,
		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
    });
}
function playListEditPost(){
	mccmsa.ajax({
        url:"activity/editAct",
        method:"POST",
		data:{
			"actId":$("#onClickDataTable tr:eq(0)").attr("actid"),
			"actTopic":$("#actTopic").val(),
			"actPhotoName":$("#preview").attr("src").substring($("#preview").attr("src").lastIndexOf("/")+1),
			"priKey":$("#priKey").val(),
			"enrollPrice":$("#enrollPrice").val(),
			"enrollLimit":$("#enrollLimit").val(),
			"moreDetails":editor.getContent(),
			"address":$("#address").val(),
			"detailAdd":$("#detailAdd").val(),
			"beginTime":$("#beginTime").val(),
			"endTime":$("#endTime").val(),
			"enrollBeginTime":$("#enrollBeginTime").val(),
			"enrollEndTime":$("#enrollEndTime").val(),
			"status":$(".select option:selected").val()
		},
        success:function(json){
        	alert(json.message);
        	playList();
        }
    })
}


//新增数据

function playListNew(){
	mccmsa.ajax({
        url:"activity/getById/1",
        method:"GET",
        success:function(json){
        	
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navNewData",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getNewData",
                container: $("#onClickDataTable")
            });
            
            $("#playList").hide();
            $("#onClickDataTable").show(); 
            
            dataLay();
            
            //获取滚动条宽度并赋值到表头padding-right，对齐
        	//实例化编辑器
        	//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
            editor = new UE.ui.Editor();
            editor.render("editor");
            
            $("#onClickDataTable>tbody>tr:last").after('<tr><td class="col-1 table-bgc-f5"></td><td class="text-l col-11"> <input class="btn btn-primary radius"  onClick="playListPostNew()" type="submit" value="提交"></td></tr>');
        }
    })  
}
function playListPostNew(){
	mccmsa.ajax({
        url:"activity/addAct",
        method:"POST",
        data:{
			"actId":$("#onClickDataTable tr:eq(0)").attr("actid"),
			"actTopic":$("#actTopic").val(),
			"actPhotoName":$("#preview").attr("src").substring($("#preview").attr("src").lastIndexOf("/")+1),
			"priKey":$("#priKey").val(),
			"enrollPrice":$("#enrollPrice").val(),
			"enrollLimit":$("#enrollLimit").val(),
			"moreDetails":editor.getContent(),
			"address":$("#address").val(),
			"detailAdd":$("#detailAdd").val(),
			"beginTime":$("#beginTime").val(),
			"endTime":$("#endTime").val(),
			"enrollBeginTime":$("#enrollBeginTime").val(),
			"enrollEndTime":$("#enrollEndTime").val(),
			"status":$(".select option:selected").val()
		},
        success:function(json){
        	alert(json.message);
        	playList();
        }
    })
}

//删除
function playListDel(obj){
	$("#myModal").attr("actid",$(obj).parents("tr").attr("actId"));
}
function playListDelSure(obj){
	mccmsa.ajax({
        url:"activity/delAct/"+$("#myModal").attr("actid"),
        method:"POST",
        success:function(json){
        	alert(json.message);
        	$(".close").click();
        	playList();
        }
    })
}



/*活动end*/

/*参与人*/
function participant(obj){
	var actid = $(obj).parents("tr").attr("actid");
	mccmsa.getHtmlFromRemoteTemplate({
        templateName:"participant.hbs",
        container: $("#mainContainer")
    });
	new participantList(1,actid);
}
function participantList(pageNo,actid){
	if(!actid){
		actid=$("#participantList").attr("actid")
	}
	if(!pageNo){
		pageNo=1
	}
	mccmsa.ajax({
        url:"back/activity/attendee/getByAct/"+actid+"?pageSize=8&pageNo="+pageNo,
        method:"GET",
        success:function(json){
        	for(var i in json.result.resultList){
				json.result.resultList[i].enrollTime=returnDate(json.result.resultList[i].enrollTime);
				json.result.resultList[i].status=returnStatus(json.result.resultList[i].status);
			}
        	
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        		templateId: "navMain",
        		container: $("#pathContainer")
        	});

        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        		templateId: "getColumnTableData",
        		container: $("#ColumnTableData"),
        		data:json
        	});
        	if(actid){
        		$("#participantList").attr("actid",actid);
        	}
        	if(json.result.resultList[0]!=null){
        		$("#pathContainer input").attr("activityId",json.result.resultList[0].activityId);
        	}
        	$("#participantList").show();
        	$("#htmlCheckContent,#onClickDataTable").hide();
        	pageHtml(json);		//生成分页
        }
    })
}
//编辑
function participantEdit(obj){
	mccmsa.ajax({
        url:"back/activity/attendee/getById/"+$(obj).parents("tr").attr("actAttId"),
        method:"GET",
        success:function(json){
        	json.result.enrollTime=returnDate(json.result.enrollTime);
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navEdit",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getEditData",
                container: $("#onClickDataTable"),
                data:json
            });
            if(json.result.attSex=="男"){
            	$("#select option:eq(0)").attr("selected","selected");
            }else if(json.result.attSex=="女"){
            	$("#select option:eq(1)").attr("selected","selected");
            }

            laydate({
                elem: '#bornDate',
        		format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
            });
            
            $("#participantList").hide();
            $("#onClickDataTable").show(); 
        }
    })
}
function participantEditPost(){
	mccmsa.ajax({
        url:"back/activity/attendee/editAtt",
        method:"POST",
        data:{
        	"actAttId":$("#onClickDataTable>tbody>tr:eq(0)").attr("actAttId"),
        	"attName":$("#attName").val(),
        	"attSex":$("#select").val(),
        	"attPhone":$("#attPhone").val(),
        	"attIdNum":$("#attIdNum").val(),
        	"bornDate":$("#bornDate").val(),
        	"attComment":$("#attComment").val(),
        	"status":"1"
        },
        success:function(json){
        	alert(json.message);
        	participantList();
        }
    })
}
//新增
function participantNew(obj){
	var activityid = $(obj).attr("activityid");
	mccmsa.ajax({
        url:"back/activity/attendee/getById/1",
        method:"GET",
        success:function(json){
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navNewData",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getNewData",
                container: $("#onClickDataTable")
            });

            
            laydate({
                elem: '#bornDateNew',
        		format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
            });
            
            $("#participantNewPost").attr("activityid",activityid);
            $("#participantList").hide();
            $("#onClickDataTable").show();
        }
    })
    	
}

function participantNewPost(obj){
	mccmsa.ajax({
        url:"back/activity/attendee/addAtt",
        method:"POST",
        data:{
        	"activityId":$("#participantList").attr("actid"),
        	"attName":$("#attName").val(),
        	"attSex":$("#select").val(),
        	"attPhone":$("#attPhone").val(),
        	"attIdNum":$("#attIdNum").val(),
        	"bornDate":$("#bornDateNew").val(),
        	"attComment":$("#attComment").val(),
        	"status":"1"
        },
        success:function(json){
        	alert(json.message);
        	participantList();
        }
    })
}

//删除
function participantDel(obj){
	$("#myModal").attr("actattid",$(obj).parents("tr").attr("actattid"));
}
function participantDelPost(){
	mccmsa.ajax({
        url:"back/activity/attendee/delAtt/"+$("#myModal").attr("actattid"),
        method:"DELETE",
        success:function(json){
        	alert(json.message);
        	participantList();
        	$(".close").click();
        }
    })
}
/*参与人end*/


/*会员列表*/
function memberList(pageNo){
	 //给栏目表录入数据
	if(!pageNo){pageNo=1}		//分页页数
    mccmsa.ajax({
        url:"member/getMemberAll?pageNo="+pageNo+"&pageSize=8",
        method:"Get",
        success:function(json){
        	for(var i in json.result.resultList){
        		json.result.resultList[i].regisTime=returnDate(json.result.resultList[i].regisTime);
        		json.result.resultList[i].status=returnStatusMember(json.result.resultList[i].status);
        	}
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navMain",
                container: $("#pathContainer")
            });
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData",
                container: $("#ColumnTableData"),
                data:json
            });
			pageHtml(json);		//生成分页
            $("#memberList").show();
            $("#onClickDataTable,.memberNav").hide(); 
            
            var scrollbarWidth = $('.table-maxHeight')[0].offsetWidth - $('.table-maxHeight')[0].scrollWidth;
            $("table:eq(0)").css("paddingRight",scrollbarWidth);    //获取滚动条宽度并赋值到表头padding-right，对齐
            $(".layPage").hide();
        }
    })
}
//密码
function setPasswordMember(obj){//修改密码内容框
		var id = $(obj).parents("tr").attr("comid");
		var mobile = $(obj).attr("mobile");
		mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
			templateId: "navPassword",
			container: $("#pathContainer")
		});
		mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
			templateId: "getSetPassword",
			container: $("#onClickDataTable"),
		});
		$("#onClickDataTable tr:first").attr({
			"memberid":id,
			"mobile":mobile
		});
		$("#onClickDataTable").show();
        $("#memberList,.memberNav").hide();
        $("#memberPost").attr("userName",$(obj).attr("userName"));
}
function postPasswordMember(obj){//提交修改密码内容框
	mccmsa.ajax({
		url:"member/updateAccountSafe", //需要添加参数，看接口需要
		method:"POST",
		data:{
			"id":$("#onClickDataTable tr:first").attr("memberid"),
			"mobile":$("#onClickDataTable tr:first").attr("mobile"),
			"username":$("#memberPost").attr("userName"),
			"userPassword":$("#userPassword").val(),
			"newPassword":$("#newPassword").val()
		},
		success:function(json){
			alert(json.message);
			$("#pathContainer input").click();
		}
	})
}
//查看
function memberCheck(obj,id){
	if(obj!=""){
		id=$(obj).parents("tr").attr("comId");
	}
	mccmsa.ajax({
        url:"member/getMemberInfo/"+id,
        method:"GET",
        success:function(json){
        	json.result.birthday=returnDateDay(json.result.birthday);
        	
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navCheck",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckData",
                container: $("#onClickDataTable"),
                data:json
            });
            $("#onClickDataTable,.memberNav").show();
            $("#memberList").hide();
            
            $("#preview").attr("src","upload/enterprice/image/"+json.result.userHead);
            $(".memberNav").attr("comId",$(obj).parents("tr").attr("comId"));
            if(!json.result.identity[0]){json.result.identity[0]=""}
            if(!json.result.memberLevel){json.result.memberLevel=""}
            getDrVip(json.result.identity[0].id,json.result.memberLevel.id);
            isMemberCheck();//判断是否查看，否则table的border为0
            $("#status option[value='"+json.result.status+"']").attr("selected","selected");
            $("#isBlock option[value='"+json.result.isBlock+"']").attr("selected","selected");
            $("#regisFrom option[value='"+json.result.regisFrom+"']").attr("selected","selected");
            $(".layPage").hide();
        }
    })
}
$(function(){
	$("#mainContainer").on("click",".memberNav ul li",function(){
		var val = $(this).index();
		var id = $(".memberNav").attr("comId");
		$(".tip").removeClass("tip");
		$(this).addClass("tip");
		switch(val){
			case 0:
				return memberCheck("",id);
			case 1:
				$(".layPage").attr("fun","memberDynamicList");
				return memberDynamicList("",id);
			case 2:
				return memberBasisData(id);
			case 3:
				$(".layPage").attr("fun","memberlinkmanData")
				return memberlinkmanData("",id);
			case 4:
				$(".layPage").attr("fun","memberCheckupReporting")
				return memberCheckupReporting("",id);
		}
	})
})


function memberDynamicList(pageNo,id){
	if(!pageNo){pageNo=1}
	if(!id){id=$(".memberNav").attr("comId")}
	mccmsa.ajax({
        url:"users/getDynamicByAccountId/"+id+"?pageNo="+pageNo+"&pageSize=8",
        method:"GET",
        success:function(json){
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
        	for(var i in json.result.resultList){
        		json.result.resultList[i].checkTime=returnDate(json.result.resultList[i].checkTime);
        	}
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckDynamicData",
                container: $("#onClickDataTable"),
                data:json
            });
            pageHtml(json,$(".layPage"))
    		$(".layPage").show();
        }
    })
}
function memberDynamicEdit(obj){
	var id = $(obj).parents("tr").attr("comid");
	mccmsa.ajax({
        url:"users/getDynamicDataById/"+id,
        method:"GET",
        success:function(json){
        	json.result.checkTime=returnDateDay(json.result.checkTime);
        	json.result.sleep.hypnagogicTime=returnDate(json.result.sleep.hypnagogicTime);
        	
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckDynamicEdit",
                container: $("#onClickDataTable"),
                data:json
            });
            laydate({
                elem: '#checkTime',
        		format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
            });
        	laydate({
                elem: '#hypnagogicTime',
                istime: true,
        		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
            });
        	
        	$("#isSleep option[value='"+json.result.sleep.sleepQuality+"']").attr("selected","selected");
        	$("#isSiesta option[value='"+json.result.sleep.afternoonNap+"']").attr("selected","selected");
        	$("#defecate option[value='"+json.result.defecate+"']").attr("selected","selected");
        	$("#apptite option[value='"+json.result.apptite+"']").attr("selected","selected");
        	$("#threeMeals option[value='"+json.result.threeMeals+"']").attr("selected","selected");
        	$("#smoothBowel option[value='"+json.result.smoothBowel+"']").attr("selected","selected");
        	
        	for(var i in json.result.emotion){
        		$("#is-emotion label").each(function(){
        			if($(this).text()==json.result.emotion[i].name){
        				$(this).prev().prop("checked",true);
        			}
        		});
        	}
        	for(var i in json.result.sports){
        		$("#is-sport label").each(function(){
        			if($(this).text()==json.result.sports[i].name){
        				$(this).prev().prop("checked",true);
        			}
        		});
        	}
        	
        	$("#memberDynamicNewPost").attr("comId",id);
            $(".layPage").hide();
        }
    })
}
function memberDynamicEditPost(obj){
	var sport = "[";
	var emotions = "["
	$("#is-emotion input").each(function(){
		if($(this).prop("checked")){
			emotions+= "{'name':'"+$(this).next().text()+"'},";
		}
	})
	$("#is-sport input").each(function(){
		if($(this).prop("checked")){
			sport+= "{'name':'"+$(this).next().text()+"'},";
		}
	})
	emotions = emotions.substring(0,emotions.length-1)+"]";
	sport = sport.substring(0,sport.length-1)+"]";
	mccmsa.ajax({
        url:"users/editDynamicData",
        method:"POST",
        data:{
        	"id":$("#memberDynamicNewPost").attr("comId"),
        	"defecate":$("#defecate").val(),
        	"temperature":$("#temperature").val(),
        	"systolicPressure":$("#systolicPressure").val(),
        	"diastolicPressure":$("#diastolicPressure").val(),
        	"bloodGlucose":$("#bloodGlucose").val(),
        	"heartRate":$("#heartRate").val(),
        	"checkTime":$("#checkTime").val(),
        	"sport":(sport.length-1)?sport:undefined,
        	"emotions":(emotions.length-1)?emotions:undefined,
        	"apptite":$("#apptite").val(),
        	"threeMeals":$("#threeMeals").val(),
        	"waterIntake":$("#waterIntake").val(),
        	"runDuration":$("#runDuration").val(),
        	"smoothBowel":$("#smoothBowel").val(),
        	"micturitionUnmber":$("#micturitionUnmber").val(),
        	"sleep.hypnagogicTime":$("#hypnagogicTime").val(),
        	"sleep.sleepTime":$("#sleepTime").val(),
        	"sleep.sleepQuality":$("#isSleep").val(),
        	"sleep.afternoonNap":$("#isSiesta").val()
        },
        success:function(json){
        		alert(json.message);
        		memberDynamicList();
        }
    })
}



function memberDynamicNew(){
    mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "getCheckDynamicNew",
        container: $("#onClickDataTable")
    });
    setTimeout(function(){
    	laydate({
            elem: '#checkTime',
    		format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
        });
    	laydate({
            elem: '#hypnagogicTime',
            istime: true,
    		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
        });
    },100)
    $(".layPage").hide();
}
function memberDynamicNewPost(){
	var sport = "[";
	var emotions = "["
	$("#is-emotion input").each(function(){
		if($(this).prop("checked")){
			emotions+= "{'name':'"+$(this).next().text()+"'},";
		}
	})
	$("#is-sport input").each(function(){
		if($(this).prop("checked")){
			sport+= "{'name':'"+$(this).next().text()+"'},";
		}
	})
	emotions = emotions.substring(0,emotions.length-1)+"]";
	sport = sport.substring(0,sport.length-1)+"]";
	mccmsa.ajax({
        url:"users/addDynamic",
        method:"POST",
        data:{
        	"accountId":$(".memberNav").attr("comId"),
        	"defecate":$("#defecate").val(),
        	"temperature":$("#temperature").val(),
        	"systolicPressure":$("#systolicPressure").val(),
        	"diastolicPressure":$("#diastolicPressure").val(),
        	"bloodGlucose":$("#bloodGlucose").val(),
        	"heartRate":$("#heartRate").val(),
        	"checkTime":$("#checkTime").val(),
        	"sport":(sport.length-1)?sport:undefined,
        	"emotions":(emotions.length-1)?emotions:undefined,
        	"apptite":$("#apptite").val(),
        	"threeMeals":$("#threeMeals").val(),
        	"waterIntake":$("#waterIntake").val(),
        	"runDuration":$("#runDuration").val(),
        	"smoothBowel":$("#smoothBowel").val(),
        	"micturitionUnmber":$("#micturitionUnmber").val(),
        	"sleep.hypnagogicTime":$("#hypnagogicTime").val(),
        	"sleep.sleepTime":$("#sleepTime").val(),
        	"sleep.sleepQuality":$("#isSleep").val(),
        	"sleep.afternoonNap":$("#isSiesta").val()
        },
        success:function(json){
        	alert(json.message);
        	memberDynamicList();
        }
    })
}





function memberBasisData(id){
	mccmsa.ajax({
        url:"users/getDataByAccountId/"+id,
        method:"GET",
        success:function(json){
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckBasisData",
                container: $("#onClickDataTable"),
                data:json
            });
            $(".layPage").hide();
        }
    })
}

function memberlinkmanData(pageNo,id){
	//给栏目表录入数据
	if(!pageNo){pageNo=1}		//分页页数
	if(!id){id=$("#onClickDataTable").attr("comid")}
	mccmsa.ajax({
        url:"users/getContactByAccountId/"+id+"?pageNo="+pageNo+"&pageSize=8",
        method:"GET",
        success:function(json){
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckLinkmanData",
                container: $("#onClickDataTable"),
                data:json
            });
            $("#onClickDataTable").attr("comid",id);
            pageHtml(json,$(".layPage"))
    		$(".layPage").show();
        }
		
    })
}
function memberlinkmanEdit(obj){
	var id = $(obj).parents("tr").attr("comid");
	mccmsa.ajax({
        url:"users/getEmergencyContactById/"+id,
        method:"GET",
        success:function(json){
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckLinkmanEdit",
                container: $("#onClickDataTable"),
                data:json.result
            });
        	$(".layPage").hide();
        }
    })
}
function memberlinkmanEditPost(obj){
	mccmsa.ajax({
        url:"users/editContact",
        method:"POST",
        data:{
        	"id":$(obj).attr("linkId"),
        	"accountId":$(".memberNav").attr("comId"),
        	"name":$("#name").val(),
        	"relation":$("#relation").val(),
        	"phone":$("#phone").val()
        },
        success:function(json){
        	alert(json.message);
        	memberlinkmanData();
        }
    })
}



function memberlinkmanNew(){
	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "getCheckLinkmanNew",
        container: $("#onClickDataTable")
    });
    $(".layPage").hide();
}
function memberlinkmanNewPost(){
	mccmsa.ajax({
        url:"users/newContact",
        method:"POST",
        data:{
        	"accountId":$(".memberNav").attr("comId"),
        	"name":$("#name").val(),
        	"relation":$("#relation").val(),
        	"phone":$("#phone").val()
        },
        success:function(json){
        	alert(json.message);
        	memberlinkmanData();
        }
		
    })
}



function memberCheckupReporting(pageNo,id){		//体检报告
	//给栏目表录入数据
	if(!pageNo){pageNo=1}		//分页页数
	if(!id){id=$(".memberNav").attr("comid")}
	mccmsa.ajax({
        url:"admin/report/"+id+"/getPhysicalReportAll?pageNo="+pageNo+"&pageSize=8",
        method:"GET",
        success:function(json){
        	for(var i in json.result.resultList){
        		json.result.resultList[i].reportDate=returnDate(json.result.resultList[i].reportDate);
        		json.result.resultList[i].createTime=returnDate(json.result.resultList[i].createTime);
        		if(json.result.resultList[i].filePath){
        			json.result.resultList[i].filePath=json.result.resultList[i].filePath.substring(1);
        		}
        	}
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckupReporting",
                container: $("#onClickDataTable"),
                data:json
            });
            $("#onClickDataTable tr:eq(0)").attr("comId",id);
            pageHtml(json,$(".layPage"));
            $(".layPage").show();
        }
    })
}
//编辑
function getCheckupReportingEdit(obj){
	mccmsa.ajax({
        url:"admin/report/getPhysicalReport/"+$(obj).parents("tr").attr("comId"),
        method:"Get",
        success:function(json){
        	json.result.reportDate=returnDate(json.result.reportDate);
        	json.result.createTime=returnDate(json.result.createTime);

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckupReportingEdit",
                container: $("#onClickDataTable"),
                data:json.result
            });
            
            if(json.result.filePath!=null){
				$("#file").attr("src",json.result.filePath)
				$("#file").parent().find(".shadeFile").html(json.result.filePath.substring(json.result.filePath.lastIndexOf("/")+1))
			}
            
            laydate({
                elem: '#reportDate',
                istime: true,
        		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
            });
            laydate({
                elem: '#createTime',
                istime: true,
        		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
            });
            $("#getCheckupReportingEditPost").attr("comId",$(obj).parents("tr").attr("comId"));
            $("#onClickDataTable").show();
            $("#VipList,.layPage").hide(); 
        }
    })
}
function getCheckupReportingEditPost(obj){
	mccmsa.ajax({
        url:"admin/report/modifyPhysicalReport",
        method:"post",
        data:{
        	"id":$(obj).attr("comId"),
        	"fileName":$("#fileName").val(),
        	"filePath":$(".shadeFile").attr("path"),
        	"reportDate":$("#reportDate").val(),
        	"reportProvider":$("#reportProvider").val(),
        	"createTime":$("#createTime").val(),
        	"status":"1",
        	"memberId":$(".memberNav").attr("comId"),
        },
        success:function(json){
        	alert(json.message);
        	memberCheckupReporting("",$(".memberNav").attr("comId"));
        }
    })
}
//新增
function getCheckupReportingNew(obj){
	mccmsa.ajax({
        url:"admin/report/getPhysicalReport/1",
        method:"Get",
        success:function(json){
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getCheckupReportingNew",
                container: $("#onClickDataTable"),
                data:json.result
            });
            
            laydate({
                elem: '#reportDate',
                istime: true,
        		format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
            });

            $("#onClickDataTable").show();
            $("#VipList,.layPage").hide(); 
        }
    })
}
function getCheckupReportingPost(obj){
	mccmsa.ajax({
        url:"admin/report/addPhysicalReport",
        method:"post",
        data:{
        	"fileName":$("#fileName").val(),
        	"filePath":$(".shadeFile").attr("path"),
        	"reportDate":$("#reportDate").val(),
        	"reportProvider":$("#reportProvider").val(),
        	"memberId":$(".memberNav").attr("comId"),
        },
        success:function(json){
        	alert(json.message);
        	memberCheckupReporting("",$(".memberNav").attr("comId"));
        }
    })
}

function isMemberCheck(){		//判断是否进入会员查看页面
	if($(".memberNav").css("display")!="none"){
		$("#onClickDataTable").css({
			"borderTop":"1px solid #dfdfdf",
			"borderLeft":"1px solid #dfdfdf"
		})
	}else{
		
		$("#onClickDataTable").css({
			"border":"0",
		})
	}
}

//编辑
function memberEdit(obj){
	mccmsa.ajax({
        url:"member/getMemberInfo/"+$(obj).parents("tr").attr("comId"),
        method:"GET",
        success:function(json){
        	json.result.birthday=returnDateDay(json.result.birthday);
        	
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navEdit",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getEditData",
                container: $("#onClickDataTable"),
                data:json
            });
            $("#onClickDataTable").show();
            $("#memberList,.memberNav").hide();
            isMemberCheck();//判断是否查看，否则table的border为0
            $("#status option[value='"+json.result.status+"']").attr("selected","selected");
            $("#isBlock option[value='"+json.result.isBlock+"']").attr("selected","selected");
            $("#regisFrom option[value='"+json.result.regisFrom+"']").attr("selected","selected");
            
            if(json.result.userHead!=null){
				$("#preview").attr("src","upload/enterprice/image/"+json.result.userHead);
				$("#preview").parent().find(".shadeFile").html(json.result.userHead.substring(json.result.userHead.lastIndexOf("/")+1))
			}
            if(!json.result.identity[0]){json.result.identity[0]=""}
            if(!json.result.memberLevel){json.result.memberLevel=""}
            getDrVip(json.result.identity[0].id,json.result.memberLevel.id);
            laydate({
                elem: '#birthday',
        		format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
            });
        }
    })
}
function getDrVip(ide,vip){		//获取vip和身份
	mccmsa.ajax({
        url:"users/getAll",
        method:"Get",
        success:function(json){
        	var html = '';
        	for(var i in json.result){
        		html+='<option value="'+json.result[i].id+'">'+json.result[i].name+'</option>'
        	}
        	$("#isIdentity").html(html);
        	$("#isIdentity option[value='"+ide+"']").attr("selected","selected");
        }
    })   
    mccmsa.ajax({
        url:"users/getLevel",
        method:"Get",
        success:function(json){
        	var html = '';
        	for(var i in json.result.resultList){
        		html+='<option value="'+json.result.resultList[i].id+'">'+json.result.resultList[i].level+'</option>'
        	}
        	
        	$("#isVip").html(html);
        	$("#isVip option[value='"+vip+"']").attr("selected","selected");
        }
    })
}
function memberEditPost(){
	mccmsa.ajax({
        url:"member/updateAccountInfo",
        method:"POST",
        data:{
        	"id":$("#onClickDataTable>tr:eq(0)").attr("comId"),
        	"username":$("#username").val(),
        	"nickname":$("#nickname").val(),
        	"mobile":$("#mobile").val(),
        	"sex":$("#sex").val(),
        	"realName":$("#realName").val(),
        	"birthday":$("#birthday").val(),
        	"qq":$("#qq").val(),
        	"email":$("#email").val(),
        	"postcode":$("#postcode").val(),
        	"address":$("#address").val(),
        	"area":$("#area").val(),
        	"userHead":$("#preview").attr("src").substring($("#preview").attr("src").lastIndexOf("/")+1),
        	"regisFrom":$("#regisFrom").val(),
        	"isBlock":$("#isBlock").val(),
        	"idenId":$("#isIdentity").val(),
        	"vipId":$("#isVip").val(),
        	"status":$("#status").val()
        },
        success:function(json){
        	alert(json.message)
        	memberList();
        }
    })
}


//新增
function memberNew(obj){
	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "navNewData",
        container: $("#pathContainer")
    });

    mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "getNewData",
        container: $("#onClickDataTable")
    });
    $("#onClickDataTable").show();
    $("#memberList,.memberNav").hide();
    getDrVip();
    isMemberCheck();//判断是否查看，否则table的border为0
    setTimeout(function(){laydate({
        elem: '#birthday',
		format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
    }),1000})
    
}
function memberNewPost(username){
	mccmsa.ajax({
        url:"member/addAccount",
        method:"POST",
        data:{
        	"username":$("#username").val(),
        	"password":$("#password").val(),
        	"nickname":$("#nickname").val(),
        	"mobile":$("#mobile").val(),
        	"sex":$("#sex").val(),
        	"realName":$("#realName").val(),
        	"birthday":$("#birthday").val(),
        	"qq":$("#qq").val(),
        	"email":$("#email").val(),
        	"postcode":$("#postcode").val(),
        	"address":$("#address").val(),
        	"area":$("#area").val(),
        	"userHead":$("#preview").attr("src").substring($("#preview").attr("src").lastIndexOf("/")+1),
        	"regisFrom":$("#regisFrom").val(),
        	"isBlock":$("#isBlock").val(),
        	"idenId":$("#isIdentity").val(),
        	"vipId":$("#isVip").val(),
        	"status":$("#status").val()
        },
        success:function(json){
        	alert(json.message);
        	memberList();
        }
    })
}


function memberDel(obj,val){
	$("#myModal").attr("actattid",$(obj).parents("tr").attr("comId"));
	$("#myModal").attr("val",val);
}
function memberDelPost(){
	var val = $("#myModal").attr("val");
	switch(val){
		case "1":
			mccmsa.ajax({
		        url:"member/delMember/"+$("#myModal").attr("actattid"),
		        method:"POST",
		        data:{
		        	//"id":$("#myModal").attr("actattid"),
		        	"_method":"delete"
		        },
		        success:function(json){
		        	alert(json.message);
		        	memberList();
		        	$(".close").click();
		        }
		    })
		break;
		case "2":
			mccmsa.ajax({
		        url:"admin/report/delPhysicalReport/"+$("#myModal").attr("actattid"),
		        method:"DELETE",
		        success:function(json){
		        	memberCheckupReporting("",$(".memberNav").attr("comid"));
		        	$(".close").click();
		        }
		    })
		break;
		case "3":
			mccmsa.ajax({
		        url:"users/deleteDynamic/"+$("#myModal").attr("actattid"),
		        method:"GET",
		        success:function(json){
		        	memberDynamicList();
		        	$(".close").click();
		        }
		    })
		break;
		case "4":
			mccmsa.ajax({
		        url:"users/deleteContact/"+$("#myModal").attr("actattid"),
		        method:"GET",
		        success:function(json){
		        	memberlinkmanData();
		        	$(".close").click();
		        }
		    })
		break;
	}
	
}
/*会员列表end*/


/*动态数据管理列表*/
function dynamicDataList(pageNo){
	 //给栏目表录入数据
	if(!pageNo){pageNo=1}		//分页页数
    mccmsa.ajax({
        url:"users/getDynamicDataList?pageNo="+pageNo+"&pageSize=8",
        method:"Get",
        success:function(json){
        	for(var i in json.result.resultList){
        		json.result.resultList[i].checkTime=returnDate(json.result.resultList[i].checkTime);
        	}
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navMain",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData",
                container: $("#ColumnTableData"),
                data:json
            });
			pageHtml(json);		//生成分页
            $("#dynamicDataList").show();
            $("#onClickDataTable").hide(); 
			
            var scrollbarWidth = $('.table-maxHeight')[0].offsetWidth - $('.table-maxHeight')[0].scrollWidth;
            $("table:eq(0)").css("paddingRight",scrollbarWidth);    //获取滚动条宽度并赋值到表头padding-right，对齐
        }
    })
}
function dynamicDataEdit(obj){
	mccmsa.ajax({
        url:"users/getDynamicDataById/"+$(obj).parents("tr").attr("comId"),
        method:"GET",
        success:function(json){
        	json.result.birthday=returnDateDay(json.result.birthday);
        	
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navEdit",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getEditData",
                container: $("#onClickDataTable"),
                data:json
            });
            $("#onClickDataTable").show();
            $("#dynamicDataList").hide();
            
        }
    })
}
function dynamicDataEditPost(){
	mccmsa.ajax({
        url:"users/editDynamicData",
        method:"POST",
        data:{
        	"id":$("#onClickDataTable>tbody>tr:eq(0)").attr("comId"),
        	"defecate":$("#defecate").val(),
        	"temperature":$("#temperature").val(),
        	"systolicPressure":$("#systolicPressure").val(),
        	"diastolicPressure":$("#diastolicPressure").val(),
        	"bloodGlucose":$("#bloodGlucose").val(),
        	"heartRate":$("#heartRate").val(),
        	"apptite":$("#apptite").val(),
        	"threeMeals":$("#threeMeals").val(),
        	"fruitsIntale":$("#fruitsIntale").val(),
        	"waterIntake":$("#waterIntake").val(),
        	"runDuration":$("#runDuration").val(),
        	"smoothBowel":$("#smoothBowel").val(),
        	"micturitionUnmber":$("#micturitionUnmber").val()
        },
        success:function(json){
        	alert(json.message);
        	dynamicDataList();
        }
    })
}


//新增
function dynamicDataNew(obj){
	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "navNewData",
        container: $("#pathContainer")
    });

    mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "getNewData",
        container: $("#onClickDataTable")
    });
    $("#onClickDataTable").show();
    $("#dynamicDataList").hide();
    
}
function dynamicDataNewPost(username){
	mccmsa.ajax({
        url:"users/addDynamic",
        method:"POST",
        data:{
        	"accountId":$("#username").val(),
        	"defecate":$("#defecate").val(),
        	"temperature":$("#temperature").val(),
        	"systolicPressure":$("#systolicPressure").val(),
        	"diastolicPressure":$("#diastolicPressure").val(),
        	"bloodGlucose":$("#bloodGlucose").val(),
        	"heartRate":$("#heartRate").val(),
        	"apptite":$("#apptite").val(),
        	"threeMeals":$("#threeMeals").val(),
        	"fruitsIntale":$("#fruitsIntale").val(),
        	"waterIntake":$("#waterIntake").val(),
        	"runDuration":$("#runDuration").val(),
        	"smoothBowel":$("#smoothBowel").val(),
        	"micturitionUnmber":$("#micturitionUnmber").val()
        },
        success:function(json){
        	alert(json.message);
        	dynamicDataList();
        }
    })
}


function dynamicDataDel(obj){
	$("#myModal").attr("actattid",$(obj).parents("tr").attr("comId"));
}
function dynamicDataDelPost(){
	mccmsa.ajax({
        url:"users /deleteDynamic/"+$("#myModal").attr("actattid"),
        method:"GET",
        success:function(json){
        	dynamicDataList();
        	$(".close").click();
        }
    })
}
/*动态数据管理end*/

/*达人管理*/
function intelligentList(){
    mccmsa.ajax({
        url:"users/getAll",
        method:"Get",
        success:function(json){
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navMain",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData",
                container: $("#ColumnTableData"),
                data:json
            });
            $("#intelligentList").show();
            $("#onClickDataTable,.memberNav").hide(); 
            
            var scrollbarWidth = $('.table-maxHeight')[0].offsetWidth - $('.table-maxHeight')[0].scrollWidth;
            $("table:eq(0)").css("paddingRight",scrollbarWidth);    //获取滚动条宽度并赋值到表头padding-right，对齐
        }
    })
}

//新增
function intelligentNew(obj){
	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "navNewData",
        container: $("#pathContainer")
    });

    mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "getNewData",
        container: $("#onClickDataTable")
    });
    $("#onClickDataTable").show();
    $("#intelligentList").hide(); 
}
function intelligentNewPost(){
	mccmsa.ajax({
        url:"users/addIndentity",
        method:"POST",
        data:{
        	"name":$("#name").val()
        },
        success:function(json){
        	alert(json.message);
        	intelligentList();
        }
    })
}

function intelligentListDel(obj){
	$("#myModal").attr("actattid",$(obj).parents("tr").attr("comId"));
}
function intelligentListDelPost(){
	mccmsa.ajax({
        url:"users/deleteIndentity/"+$("#myModal").attr("actattid"),
        method:"GET",
        success:function(json){
        	intelligentList();
        	$(".close").click();
        }
    })
}
/*达人管理end*/

/*VIP管理*/
function VipList(){
    mccmsa.ajax({
        url:"users/getLevel",
        method:"Get",
        success:function(json){
        	
        	Handlebars.registerHelper("addOne",function(index,options){
				   return parseInt(index)+1+(json.result.pageNo-1)*json.result.pageSize;
			});
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navMain",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData",
                container: $("#ColumnTableData"),
                data:json
            });
            $("#VipList").show();
            $("#onClickDataTable,.memberNav").hide(); 
            pageHtml(json);	
            var scrollbarWidth = $('.table-maxHeight')[0].offsetWidth - $('.table-maxHeight')[0].scrollWidth;
            $("table:eq(0)").css("paddingRight",scrollbarWidth);    //获取滚动条宽度并赋值到表头padding-right，对齐
        }
    })
}
//编辑
function VipEdit(obj){
	mccmsa.ajax({
        url:"users/getMemberLevelById/"+$(obj).parents("tr").attr("comId"),
        method:"Get",
        success:function(json){
        	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "navEdit",
                container: $("#pathContainer")
            });

            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getEditData",
                container: $("#onClickDataTable"),
                data:json
            });
            $("#onClickDataTable").show();
            $("#VipList").hide();
        }
    })
}

function VipEditPost(val){
	mccmsa.ajax({
        url:"users/editLevel",
        method:"POST",
        data:{
        	"id":val,
        	"level":$("#level").val(),
        	"discount":$("#discount").val(),
        	"levelImg":$("#preview").attr("src").substring($("#preview").attr("src").lastIndexOf("/")+1),
        	"status":"1"
        },
        success:function(json){
        	alert(json.message);
        	VipList();
        }
    })
}
//新增
function VipNew(obj){
	mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "navNewData",
        container: $("#pathContainer")
    });

    mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
        templateId: "getNewData",
        container: $("#onClickDataTable")
    });
    $("#onClickDataTable").show();
    $("#VipList").hide(); 
}
function VipNewPost(){
    mccmsa.ajax({
        url:"users/addLevel",
        method:"POST",
        data:{
        	"level":$("#level").val(),
        	"discount":$("#discount").val(),
        	"levelImg":$("#preview").attr("src").substring($("#preview").attr("src").lastIndexOf("/")+1),
        	"status":"1"
        },
        success:function(json){
        	alert(json.message);
        	VipList();
        }
    })
}

function VipListDel(obj){
	$("#myModal").attr("actattid",$(obj).parents("tr").attr("comId"));
}
function VipListDelPost(){
	mccmsa.ajax({
        url:"users/deleteLevel/"+$("#myModal").attr("actattid"),
        method:"GET",
        success:function(json){
        	VipList();
        	$(".close").click();
        }
    })
}
/*VIP管理end*/


/*论坛管理*/
function forumManageList(val){
	columnManage('1',val);
}
/*论坛管理end*/



/*common function*/
function format(time, format){
    var t = new Date(time);
    var tf = function(i){return (i < 10 ? '0' : '') + i};
    return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){
        switch(a){
            case 'yyyy':
                return tf(t.getFullYear());
                break;
            case 'MM':
                return tf(t.getMonth() + 1);
                break;
            case 'mm':
                return tf(t.getMinutes());
                break;
            case 'dd':
                return tf(t.getDate());
                break;
            case 'HH':
                return tf(t.getHours());
                break;
            case 'ss':
                return tf(t.getSeconds());
                break;
        }
    })
}
function returnDate(time){		//返回标准格式时间
	return format(time, 'yyyy-MM-dd HH:mm:ss');
}
function returnDateDay(time){		//返回标准格式时间
	return format(time, 'yyyy-MM-dd');
}
function returnStatus(val){
	if(val){
		return "有效活动";
	}else{
		return "无效活动";
	}
}
function returnStatusCon(val){
	if("0"==val){
		return "未通过";
	}else if("1"==val){
		return "已通过";
	}else if("2"==val){
		return "待审核";
	}else{
		return val;
	}
}
function returnStatusMember(val){
	if("1"==val){
		return "启用";
	}else if("0"==val){
		return "禁用";
	}else if("2"==val){
		return "注销";
	}else{
		return val;
	}
}

function returnIsShowInNav(val){
	if(val==1){
		return "是";
	}else{
		return "否";
	}
}
function returnStatusCon(val){
	if(val==1){
		return "已启动";
	}else{
		return "已停用";
	}
}